<?
/*
Bitsand - a web-based booking system for LRP events
Copyright (C) 2006, 2007 Russell Peter Phillips

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

include ('inc_head_db.php');
include ('inc_head_html.php');
include ('inc_admin.php');

//Get list of players & car registration numbers
$key = CRYPT_KEY;
$sql = "SELECT AES_DECRYPT(plFirstName, '$key') AS dFirstName, " .
	"AES_DECRYPT(plSurname, '$key') AS dSurname, " .
	"AES_DECRYPT(plCarRegistration, '$key') AS dCarRegistration, " .
	"bkDatePaymentConfirmed " .
	"FROM players, bookings " .
	"WHERE plPlayerID = bkPlayerID AND bkDatePaymentConfirmed <> '0000-00-00' AND bkDatePaymentConfirmed <> '' " .
	"ORDER BY dSurname";
$result = mysqli_query ($link, $sql);

$sDisclaimerText = "By signing below, you agree to abide by the rules and regulations of the event organiser. You will not be allowed to take part in the event until and unless you sign below.";
?>

<span class = "noprint"><i>Note that this page is designed to be printed. It will look different when printed. Use Print Preview to see the difference.</i></span>

<p><?=$sDisclaimerText?></p>

<table width = "100%">
<tr><th width = '10%'>Name</th><th width = '10%'>Car Reg</th><th>Signature</th></tr>

<?
$iRowCount = 0;
while ($row = mysqli_fetch_assoc ($result)) {
	echo "<tr><td width = '10%'>" . $row ['dFirstName'] . " " . $row ['dSurname'] . "</td>";
	echo "<td width = '10%'>" . $row ['dCarRegistration'] . "</td><td>&nbsp</td></tr>\n";
	if ($iRowCount++ > 12) {
		//Start a new table and force a page break
		echo "</table>\n<p style = 'page-break-before:always'>$sDisclaimerText</p>\n<table width = '100%'>\n";
		echo "<tr><th width = '10%'>Name</th><th width = '10%'>Car Reg</th><th>Signature</th></tr>\n";
		$iRowCount = 0;
	}
}
echo "</table>";

//Close link to database
mysqli_close ($link);
?>
